package com.liuhousemyjavabasic.controller;

import com.openhtmltopdf.swing.Java2DRenderer;
import com.openhtmltopdf.util.FSImageWriter;
import org.apache.commons.io.FileUtils;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

@RestController
@RequestMapping("html_pic")
public class TestHtmlPicture {

    @GetMapping("create_png")
    public String createPng() throws Exception {
//html页面中需要灵活变动的值
        String headurl = "";//图片的路径不能是带有参数的 不然解析不了
        String proUrl = "";
        String qrCodeUrl = "";
        String proName = "犀牛皮特质皮鞋";
        String proPrice = "1000.00";
        String userName = "测试";
        String html = "\n" +
                "<!DOCTYPE html>\n" +
                "<html lang=\"en\">\n" +
                "\n" +
                "<head>\n" +
                "    <title>Document</title>\n" +
                "</head>\n" +
                "<body>\n" +
                "<table class=\"ddd\" align=\"left\" cellspacing=\"5\" cellpadding=\"2\">\n" +
                "    <caption class=\"title\">蔬菜批发对配送单        <span class=\"title_code\">(D4692024040786482895)</span>\n" +
                "            </caption>\n" +
                "    <thead>\n" +
                "    <tr>\n" +
                "        <td class=\"address\">收货单位:西安东府有渔餐厅</td>\n" +
                "        <td class=\"time\">送货时间:2024年04月08日</td>\n" +
                "    </tr>\n" +
                "    </thead>\n" +
                "    <tbody>\n" +
                "    <tr style=\"margin-right:3px;\">\n" +
                "        <td>\n" +
                "            <table border=\"1\" width=\"720\" align=\"left\" cellspacing=\"0\" cellpadding=\"2\">\n" +
                "                <thead>\n" +
                "                <tr>\n" +
                "                   <th>序号</th>\n" +
                "                   <th>名称</th>\n" +
                "                                            <th>规格</th>\n" +
                "                                       <th>数量</th>\n" +
                "                   <th>单位</th>\n" +
                "                   <th>单价</th>\n" +
                "                   <th>总价</th>\n" +
                "                </tr>\n" +
                "                </thead>\n" +
                "                <tbody align=\"center\">\n" +
                "                                <tr>\n" +
                "                   <td>1</td>\n" +
                "                   <td class=\"pr-name\">鸡</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>个</td>\n" +
                "                    <td>\n" +
                "                        33.00                       </td>\n" +
                "                    <td>\n" +
                "                       33.00                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>2</td>\n" +
                "                   <td class=\"pr-name\">豆腐</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>斤</td>\n" +
                "                    <td>\n" +
                "                        6.00                       </td>\n" +
                "                    <td>\n" +
                "                       6.00                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>3</td>\n" +
                "                   <td class=\"pr-name\">羊心</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>个</td>\n" +
                "                    <td>\n" +
                "                        14.00                       </td>\n" +
                "                    <td>\n" +
                "                       14.00                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>4</td>\n" +
                "                   <td class=\"pr-name\">糙米</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>斤</td>\n" +
                "                    <td>\n" +
                "                        66.00                       </td>\n" +
                "                    <td>\n" +
                "                       66.00                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>5</td>\n" +
                "                   <td class=\"pr-name\">玫珑</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>斤</td>\n" +
                "                    <td>\n" +
                "                        18.00                       </td>\n" +
                "                    <td>\n" +
                "                       18.00                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>6</td>\n" +
                "                   <td class=\"pr-name\">黑米</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>袋</td>\n" +
                "                    <td>\n" +
                "                        45.00                       </td>\n" +
                "                    <td>\n" +
                "                       45.00                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>7</td>\n" +
                "                   <td class=\"pr-name\">香醋</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>件</td>\n" +
                "                    <td>\n" +
                "                        60.00                       </td>\n" +
                "                    <td>\n" +
                "                       60.00                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>8</td>\n" +
                "                   <td class=\"pr-name\">沃柑</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>斤</td>\n" +
                "                    <td>\n" +
                "                        17.00                       </td>\n" +
                "                    <td>\n" +
                "                       17.00                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>9</td>\n" +
                "                   <td class=\"pr-name\">油桃</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>斤</td>\n" +
                "                    <td>\n" +
                "                        76.00                       </td>\n" +
                "                    <td>\n" +
                "                       76.00                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>10</td>\n" +
                "                   <td class=\"pr-name\">挂面</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>把</td>\n" +
                "                    <td>\n" +
                "                        12.00                       </td>\n" +
                "                    <td>\n" +
                "                       12.00                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>11</td>\n" +
                "                   <td class=\"pr-name\">羊鞭</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>根</td>\n" +
                "                    <td>\n" +
                "                        7.00                       </td>\n" +
                "                    <td>\n" +
                "                       7.00                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>12</td>\n" +
                "                   <td class=\"pr-name\">山药</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>斤</td>\n" +
                "                    <td>\n" +
                "                        8.00                       </td>\n" +
                "                    <td>\n" +
                "                       8.00                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>13</td>\n" +
                "                   <td class=\"pr-name\">中宽</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>包</td>\n" +
                "                    <td>\n" +
                "                        7.00                       </td>\n" +
                "                    <td>\n" +
                "                       7.00                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>14</td>\n" +
                "                   <td class=\"pr-name\">肚肠</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>斤</td>\n" +
                "                    <td>\n" +
                "                        23.00                       </td>\n" +
                "                    <td>\n" +
                "                       23.00                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>15</td>\n" +
                "                   <td class=\"pr-name\">牛肉</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>斤</td>\n" +
                "                    <td>\n" +
                "                        39.80                       </td>\n" +
                "                    <td>\n" +
                "                       39.80                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>16</td>\n" +
                "                   <td class=\"pr-name\">猪干</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>斤</td>\n" +
                "                    <td>\n" +
                "                        101.59                       </td>\n" +
                "                    <td>\n" +
                "                       101.59                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>17</td>\n" +
                "                   <td class=\"pr-name\">车轮</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>个</td>\n" +
                "                    <td>\n" +
                "                        4.00                       </td>\n" +
                "                    <td>\n" +
                "                       4.00                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>18</td>\n" +
                "                   <td class=\"pr-name\">青提</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>斤</td>\n" +
                "                    <td>\n" +
                "                        25.00                       </td>\n" +
                "                    <td>\n" +
                "                       25.00                    </td>\n" +
                "                </tr>\n" +
                "                                </tbody>\n" +
                "            </table>\n" +
                "        </td>\n" +
                "        <td>\n" +
                "            <table border=\"1\" width=\"720\" align=\"left\" cellspacing=\"0\" cellpadding=\"2\">\n" +
                "                <thead>\n" +
                "                <tr>\n" +
                "                   <th>序号</th>\n" +
                "                   <th>名称</th>\n" +
                "                                            <th>规格</th>\n" +
                "                                       <th>数量</th>\n" +
                "                   <th>单位</th>\n" +
                "                   <th>单价</th>\n" +
                "                   <th>总价</th>\n" +
                "                </tr>\n" +
                "                </thead>\n" +
                "                <tbody align=\"center\">\n" +
                "                                  <tr>\n" +
                "                       <td>19</td>\n" +
                "                       <td class=\"pr-name\">牛肚</td>\n" +
                "                                                <td class=\"pr-specs\"></td>\n" +
                "                                              <td>\n" +
                "                                              \t\t1                       </td>\n" +
                "                       <td>斤</td>\n" +
                "                       <td>\n" +
                "                        9.00                       </td>\n" +
                "                       <td>\n" +
                "                       9.00                       </td>\n" +
                "                   </tr>\n" +
                "                                  <tr>\n" +
                "                       <td>20</td>\n" +
                "                       <td class=\"pr-name\">茄子</td>\n" +
                "                                                <td class=\"pr-specs\"></td>\n" +
                "                                              <td>\n" +
                "                                              \t\t1                       </td>\n" +
                "                       <td>斤</td>\n" +
                "                       <td>\n" +
                "                        6.40                       </td>\n" +
                "                       <td>\n" +
                "                       6.40                       </td>\n" +
                "                   </tr>\n" +
                "                                  <tr>\n" +
                "                       <td>21</td>\n" +
                "                       <td class=\"pr-name\">烧饼</td>\n" +
                "                                                <td class=\"pr-specs\"></td>\n" +
                "                                              <td>\n" +
                "                                              \t\t1                       </td>\n" +
                "                       <td>个</td>\n" +
                "                       <td>\n" +
                "                        2.50                       </td>\n" +
                "                       <td>\n" +
                "                       2.50                       </td>\n" +
                "                   </tr>\n" +
                "                                  <tr>\n" +
                "                       <td>22</td>\n" +
                "                       <td class=\"pr-name\">料酒</td>\n" +
                "                                                <td class=\"pr-specs\">500ml</td>\n" +
                "                                              <td>\n" +
                "                                              \t\t1                       </td>\n" +
                "                       <td>件</td>\n" +
                "                       <td>\n" +
                "                        5.00                       </td>\n" +
                "                       <td>\n" +
                "                       5.00                       </td>\n" +
                "                   </tr>\n" +
                "                                  <tr>\n" +
                "                       <td>23</td>\n" +
                "                       <td class=\"pr-name\">麻油</td>\n" +
                "                                                <td class=\"pr-specs\"></td>\n" +
                "                                              <td>\n" +
                "                                              \t\t1                       </td>\n" +
                "                       <td>瓶</td>\n" +
                "                       <td>\n" +
                "                        5.00                       </td>\n" +
                "                       <td>\n" +
                "                       5.00                       </td>\n" +
                "                   </tr>\n" +
                "                                  <tr>\n" +
                "                       <td>24</td>\n" +
                "                       <td class=\"pr-name\">牛柳</td>\n" +
                "                                                <td class=\"pr-specs\"></td>\n" +
                "                                              <td>\n" +
                "                                              \t\t1                       </td>\n" +
                "                       <td>斤</td>\n" +
                "                       <td>\n" +
                "                        66.00                       </td>\n" +
                "                       <td>\n" +
                "                       66.00                       </td>\n" +
                "                   </tr>\n" +
                "                                  <tr>\n" +
                "                       <td>25</td>\n" +
                "                       <td class=\"pr-name\">小米</td>\n" +
                "                                                <td class=\"pr-specs\"></td>\n" +
                "                                              <td>\n" +
                "                                              \t\t1                       </td>\n" +
                "                       <td>斤</td>\n" +
                "                       <td>\n" +
                "                        8.00                       </td>\n" +
                "                       <td>\n" +
                "                       8.00                       </td>\n" +
                "                   </tr>\n" +
                "                                  <tr>\n" +
                "                       <td>26</td>\n" +
                "                       <td class=\"pr-name\">孜然</td>\n" +
                "                                                <td class=\"pr-specs\"></td>\n" +
                "                                              <td>\n" +
                "                                              \t\t1                       </td>\n" +
                "                       <td>斤</td>\n" +
                "                       <td>\n" +
                "                        8.00                       </td>\n" +
                "                       <td>\n" +
                "                       8.00                       </td>\n" +
                "                   </tr>\n" +
                "                                  <tr>\n" +
                "                       <td>27</td>\n" +
                "                       <td class=\"pr-name\">桔子</td>\n" +
                "                                                <td class=\"pr-specs\"></td>\n" +
                "                                              <td>\n" +
                "                                              \t\t1                       </td>\n" +
                "                       <td>斤</td>\n" +
                "                       <td>\n" +
                "                        13.50                       </td>\n" +
                "                       <td>\n" +
                "                       13.50                       </td>\n" +
                "                   </tr>\n" +
                "                                  <tr>\n" +
                "                       <td>28</td>\n" +
                "                       <td class=\"pr-name\">乔面</td>\n" +
                "                                                <td class=\"pr-specs\"></td>\n" +
                "                                              <td>\n" +
                "                                              \t\t1                       </td>\n" +
                "                       <td>袋</td>\n" +
                "                       <td>\n" +
                "                        50.00                       </td>\n" +
                "                       <td>\n" +
                "                       50.00                       </td>\n" +
                "                   </tr>\n" +
                "                                  <tr>\n" +
                "                       <td>29</td>\n" +
                "                       <td class=\"pr-name\">腐皮</td>\n" +
                "                                                <td class=\"pr-specs\"></td>\n" +
                "                                              <td>\n" +
                "                                              \t\t1                       </td>\n" +
                "                       <td>袋</td>\n" +
                "                       <td>\n" +
                "                        6.00                       </td>\n" +
                "                       <td>\n" +
                "                       6.00                       </td>\n" +
                "                   </tr>\n" +
                "                                  <tr>\n" +
                "                       <td>30</td>\n" +
                "                       <td class=\"pr-name\">黄瓜</td>\n" +
                "                                                <td class=\"pr-specs\"></td>\n" +
                "                                              <td>\n" +
                "                                              \t\t1                       </td>\n" +
                "                       <td>斤</td>\n" +
                "                       <td>\n" +
                "                        252.00                       </td>\n" +
                "                       <td>\n" +
                "                       252.00                       </td>\n" +
                "                   </tr>\n" +
                "                                  <tr>\n" +
                "                       <td>31</td>\n" +
                "                       <td class=\"pr-name\">百合</td>\n" +
                "                                                <td class=\"pr-specs\"></td>\n" +
                "                                              <td>\n" +
                "                                              \t\t1                       </td>\n" +
                "                       <td>斤</td>\n" +
                "                       <td>\n" +
                "                        63.00                       </td>\n" +
                "                       <td>\n" +
                "                       63.00                       </td>\n" +
                "                   </tr>\n" +
                "                                  <tr>\n" +
                "                       <td>32</td>\n" +
                "                       <td class=\"pr-name\">羊排</td>\n" +
                "                                                <td class=\"pr-specs\"></td>\n" +
                "                                              <td>\n" +
                "                                              \t\t1                       </td>\n" +
                "                       <td>斤</td>\n" +
                "                       <td>\n" +
                "                        36.00                       </td>\n" +
                "                       <td>\n" +
                "                       36.00                       </td>\n" +
                "                   </tr>\n" +
                "                                  <tr>\n" +
                "                       <td>33</td>\n" +
                "                       <td class=\"pr-name\">广茄</td>\n" +
                "                                                <td class=\"pr-specs\"></td>\n" +
                "                                              <td>\n" +
                "                                              \t\t1                       </td>\n" +
                "                       <td>斤</td>\n" +
                "                       <td>\n" +
                "                        8.00                       </td>\n" +
                "                       <td>\n" +
                "                       8.00                       </td>\n" +
                "                   </tr>\n" +
                "                                  <tr>\n" +
                "                       <td>34</td>\n" +
                "                       <td class=\"pr-name\">杭椒</td>\n" +
                "                                                <td class=\"pr-specs\"></td>\n" +
                "                                              <td>\n" +
                "                                              \t\t1                       </td>\n" +
                "                       <td>斤</td>\n" +
                "                       <td>\n" +
                "                        7.00                       </td>\n" +
                "                       <td>\n" +
                "                       7.00                       </td>\n" +
                "                   </tr>\n" +
                "                                  <tr>\n" +
                "                       <td>35</td>\n" +
                "                       <td class=\"pr-name\">苦瓜</td>\n" +
                "                                                <td class=\"pr-specs\"></td>\n" +
                "                                              <td>\n" +
                "                                              \t\t1                       </td>\n" +
                "                       <td>斤</td>\n" +
                "                       <td>\n" +
                "                        6.87                       </td>\n" +
                "                       <td>\n" +
                "                       6.87                       </td>\n" +
                "                   </tr>\n" +
                "                                  <tr>\n" +
                "                       <td>36</td>\n" +
                "                       <td class=\"pr-name\">豇豆</td>\n" +
                "                                                <td class=\"pr-specs\"></td>\n" +
                "                                              <td>\n" +
                "                                              \t\t1                       </td>\n" +
                "                       <td>袋</td>\n" +
                "                       <td>\n" +
                "                        33.00                       </td>\n" +
                "                       <td>\n" +
                "                       33.00                       </td>\n" +
                "                   </tr>\n" +
                "                               </tbody>\n" +
                "            </table>\n" +
                "        </td>\n" +
                "    </tr>\n" +
                "    </tbody>\n" +
                "    <tfoot>\n" +
                "    <tr>\n" +
                "        <td>合计金额大写：壹仟伍佰玖拾元壹角肆分</td>\n" +
                "        <td class=\"page_count_style\">\n" +
                "            <div> 合计金额:1590.14元</div>\n" +
                "            <div class=\"count_page\">共50项 <span class=\"count_style\">第1页/共2页</span></div>\n" +
                "        </td>\n" +
                "    </tr>\n" +
                "    <tr>\n" +
                "        <td></td>\n" +
                "    <td></td>\n" +
                "        </tr>\n" +
                "    </tfoot>\n" +
                "</table>\n" +
                "<table class=\"ddd\" align=\"left\" cellspacing=\"5\" cellpadding=\"2\">\n" +
                "    <caption class=\"title\">蔬菜批发对配送单        <span class=\"title_code\">(D4692024040786482895)</span>\n" +
                "            </caption>\n" +
                "    <thead>\n" +
                "    <tr>\n" +
                "        <td class=\"address\">收货单位:西安东府有渔餐厅</td>\n" +
                "        <td class=\"time\">送货时间:2024年04月08日</td>\n" +
                "    </tr>\n" +
                "    </thead>\n" +
                "    <tbody>\n" +
                "    <tr style=\"margin-right:3px;\">\n" +
                "        <td>\n" +
                "            <table border=\"1\" width=\"720\" align=\"left\" cellspacing=\"0\" cellpadding=\"2\">\n" +
                "                <thead>\n" +
                "                <tr>\n" +
                "                   <th>序号</th>\n" +
                "                   <th>名称</th>\n" +
                "                                            <th>规格</th>\n" +
                "                                       <th>数量</th>\n" +
                "                   <th>单位</th>\n" +
                "                   <th>单价</th>\n" +
                "                   <th>总价</th>\n" +
                "                </tr>\n" +
                "                </thead>\n" +
                "                <tbody align=\"center\">\n" +
                "                                <tr>\n" +
                "                   <td>37</td>\n" +
                "                   <td class=\"pr-name\">节瓜</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>斤</td>\n" +
                "                    <td>\n" +
                "                        5.00                       </td>\n" +
                "                    <td>\n" +
                "                       5.00                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>38</td>\n" +
                "                   <td class=\"pr-name\">尖椒</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>斤</td>\n" +
                "                    <td>\n" +
                "                        9.00                       </td>\n" +
                "                    <td>\n" +
                "                       9.00                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>39</td>\n" +
                "                   <td class=\"pr-name\">红糖</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>斤</td>\n" +
                "                    <td>\n" +
                "                        9.00                       </td>\n" +
                "                    <td>\n" +
                "                       9.00                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>40</td>\n" +
                "                   <td class=\"pr-name\">鸭子</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>斤</td>\n" +
                "                    <td>\n" +
                "                        98.59                       </td>\n" +
                "                    <td>\n" +
                "                       98.59                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>41</td>\n" +
                "                   <td class=\"pr-name\">剁椒</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>板</td>\n" +
                "                    <td>\n" +
                "                        5.00                       </td>\n" +
                "                    <td>\n" +
                "                       5.00                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>42</td>\n" +
                "                   <td class=\"pr-name\">香粉</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>斤</td>\n" +
                "                    <td>\n" +
                "                        45.59                       </td>\n" +
                "                    <td>\n" +
                "                       45.59                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>43</td>\n" +
                "                   <td class=\"pr-name\">果冻</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>斤</td>\n" +
                "                    <td>\n" +
                "                        90.00                       </td>\n" +
                "                    <td>\n" +
                "                       90.00                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>44</td>\n" +
                "                   <td class=\"pr-name\">竹笋</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>斤</td>\n" +
                "                    <td>\n" +
                "                        8.00                       </td>\n" +
                "                    <td>\n" +
                "                       8.00                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>45</td>\n" +
                "                   <td class=\"pr-name\">兔肉</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>只</td>\n" +
                "                    <td>\n" +
                "                        11.00                       </td>\n" +
                "                    <td>\n" +
                "                       11.00                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>46</td>\n" +
                "                   <td class=\"pr-name\">平菇</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>斤</td>\n" +
                "                    <td>\n" +
                "                        6.30                       </td>\n" +
                "                    <td>\n" +
                "                       6.30                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>47</td>\n" +
                "                   <td class=\"pr-name\">雪菜</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>件</td>\n" +
                "                    <td>\n" +
                "                        9.00                       </td>\n" +
                "                    <td>\n" +
                "                       9.00                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>48</td>\n" +
                "                   <td class=\"pr-name\">香菇</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>斤</td>\n" +
                "                    <td>\n" +
                "                        12.00                       </td>\n" +
                "                    <td>\n" +
                "                       12.00                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>49</td>\n" +
                "                   <td class=\"pr-name\">脐橙</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>斤</td>\n" +
                "                    <td>\n" +
                "                        126.00                       </td>\n" +
                "                    <td>\n" +
                "                       126.00                    </td>\n" +
                "                </tr>\n" +
                "                                <tr>\n" +
                "                   <td>50</td>\n" +
                "                   <td class=\"pr-name\">中葱</td>\n" +
                "                                            <td class=\"pr-specs\"></td>\n" +
                "                                       <td>\n" +
                "                                          \t\t1                   </td>\n" +
                "                   <td>斤</td>\n" +
                "                    <td>\n" +
                "                        8.00                       </td>\n" +
                "                    <td>\n" +
                "                       8.00                    </td>\n" +
                "                </tr>\n" +
                "                                <tr class='ptr'><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr class='ptr'><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr class='ptr'><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr class='ptr'><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>                </tbody>\n" +
                "            </table>\n" +
                "        </td>\n" +
                "        <td>\n" +
                "            <table border=\"1\" width=\"720\" align=\"left\" cellspacing=\"0\" cellpadding=\"2\">\n" +
                "                <thead>\n" +
                "                <tr>\n" +
                "                   <th>序号</th>\n" +
                "                   <th>名称</th>\n" +
                "                                            <th>规格</th>\n" +
                "                                       <th>数量</th>\n" +
                "                   <th>单位</th>\n" +
                "                   <th>单价</th>\n" +
                "                   <th>总价</th>\n" +
                "                </tr>\n" +
                "                </thead>\n" +
                "                <tbody align=\"center\">\n" +
                "                               <tr class='ptr'><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr class='ptr'><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr class='ptr'><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr class='ptr'><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr class='ptr'><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr class='ptr'><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr class='ptr'><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr class='ptr'><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr class='ptr'><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr class='ptr'><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr class='ptr'><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr class='ptr'><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr class='ptr'><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr class='ptr'><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr class='ptr'><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr class='ptr'><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr class='ptr'><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr class='ptr'><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>                </tbody>\n" +
                "            </table>\n" +
                "        </td>\n" +
                "    </tr>\n" +
                "    </tbody>\n" +
                "    <tfoot>\n" +
                "    <tr>\n" +
                "        <td>合计金额大写：壹仟伍佰玖拾元壹角肆分</td>\n" +
                "        <td class=\"page_count_style\">\n" +
                "            <div> 合计金额:1590.14元</div>\n" +
                "            <div class=\"count_page\">共50项 <span class=\"count_style\">第2页/共2页</span></div>\n" +
                "        </td>\n" +
                "    </tr>\n" +
                "    <tr>\n" +
                "        <td>收货人：</td>\n" +
                "    <td>送货人：</td>\n" +
                "        </tr>\n" +
                "    </tfoot>\n" +
                "</table>\n" +
                "</body>\n" +
                "\n" +
                "</html>";
        //string转为inputstream流
        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(html.getBytes());
//        File targetFile = ResourceUtils.getFile(ResourceUtils.CLASSPATH_URL_PREFIX+ "pdf/share1.html");
        File targetFile = ResourceUtils.getFile("D:\\Test\\share1.html");
//        File targetFile = ResourceUtils.getFile("//home//xbcpdf//share1.html");
//inputstream流转为file
        FileUtils.copyInputStreamToFile(byteArrayInputStream, targetFile);
//通过openhtmltopdf工具生成图片
        final Java2DRenderer renderer = new Java2DRenderer(targetFile, 740, 1000);
        final BufferedImage img = renderer.getImage();
        final FSImageWriter imageWriter = new FSImageWriter();
        imageWriter.setWriteCompressionQuality(0.9f);
//        String filePath = "//home//xbcpdf//output.png";
        String filePath = "D:\\Test\\output.png";
        imageWriter.write(img, filePath);//输出路径
        System.out.println("Done with rendering");
        return "创建图片成功";
    }


    @RequestMapping("delete_png")
    public void delete_png() {
        String filePath = "D:\\Test\\output.png";
//        String filePath = "//home//xbcpdf/output.png";
        Path path = Paths.get(filePath);
        System.out.println(path);
        try {
            Files.delete(path);
            System.out.println("文件删除成功");
        } catch (IOException e) {
            System.out.println("文件删除失败" + e.getMessage());
        }

    }

}
